<template>
  <Layout>
    <!-- Page Header -->
    <header
      class="masthead"
      :style="{
        backgroundImage: `url(http://8.131.86.203:1337${$page.article.cover.url}`
      }"
    >
      <div class="overlay"></div>
      <div class="container">
        <div class="row">
          <div class="col-lg-8 col-md-10 mx-auto">
            <div class="post-heading">
              <h1>{{$page.article.title}}</h1>
              <!-- <h2 class="subheading">Problems look mighty small from 150 miles up</h2> -->
              <span class="meta">
                Posted by
                <a href="#">
                  {{$page.article.createdBy.firstname}}
                  {{$page.article.createdBy.lastname}}
                </a>
                on August 24, 2019
              </span>
            </div>
          </div>
        </div>
      </div>
    </header>

    <!-- Post Content -->
    <article>
      <div class="container">
        <div class="row">
          <div class="col-lg-8 col-md-10 mx-auto" v-html="mdToHtml($page.article.content)"></div>
        </div>
      </div>
    </article>
  </Layout>
</template>

<page-query> 
query ($id: ID) {
  article: strapiArticle(id: $id) {
    title
    id
    content
    published_at
    cover {
      url
    }
    createdBy {
      id
      firstname
      lastname
    }
  }
}
</page-query>

<script>
import MarkdownIt from "markdown-it";
const md = new MarkdownIt();

export default {
  name: "PostPage",
  metaInfo: {
    title: "About us"
  },
  methods: {
    mdToHtml(str) {
      return md.render(str);
    }
  }
};
</script>
